package corewarsxxi.gui;

import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DragGestureEvent;
import java.awt.dnd.DragGestureListener;
import java.awt.dnd.DragSource;
import java.awt.dnd.DragSourceDragEvent;
import java.awt.dnd.DragSourceDropEvent;
import java.awt.dnd.DragSourceEvent;
import java.awt.dnd.DragSourceListener;
import java.io.IOException;
import javax.swing.JComponent;

/**
 *
 * @author ei10139
 */
public class DraggableComponent extends JComponent implements DragGestureListener, DragSourceListener {
    DragSource dragSource;

    public DraggableComponent() {
        dragSource = new DragSource();
        dragSource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY_OR_MOVE, this);
    }

    public void dragGestureRecognized(DragGestureEvent evt) {
        Transferable t = new StringSelection("aString");
        dragSource.startDrag(evt, DragSource.DefaultCopyDrop, t, this);
    }

    public void dragEnter(DragSourceDragEvent dsde) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void dragOver(DragSourceDragEvent dsde) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void dropActionChanged(DragSourceDragEvent dsde) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void dragExit(DragSourceEvent dse) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void dragDropEnd(DragSourceDropEvent dsde) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

}
